home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / jpl_c.zip / GETI.C < prev    next >
Text File  |  1986-05-18  |  1KB  |  33 lines

  1. /* 1.1  01-08-86                        (geti.c)
  2.  ************************************************************************
  3.  *            Robert C. Tausworthe                *
  4.  *            Jet Propulsion Laboratory            *
  5.  *            Pasadena, CA 91009        1986        *
  6.  ************************************************************************/
  7.  
  8. #include "defs.h"
  9. #include "stdtyp.h"
  10.  
  11. #define MAXDIGITS    6
  12.  
  13. /************************************************************************/
  14.  
  15. geti(prompt, check, low, high)    /* Print prompt on stdout, then get and
  16.                    return integer input from stdin.  If
  17.                    check is true, verify within bounds.    */
  18. /*----------------------------------------------------------------------*/
  19. STRING prompt;
  20. BOOL check;
  21. {
  22.     int value, atoi();
  23.     char s[MAXDIGITS];
  24.  
  25.     FOREVER
  26.     {    value = atoi(getns(prompt, s, MAXDIGITS - 1));
  27.         if (NOT check OR (low <= value AND value <= high))
  28.             break;
  29.         printf("\nValue out of range, please reenter:\n");
  30.     }
  31.     return (value);
  32. }
  33.